import React, { Component } from 'react';

import { recommend } from '../../utils/api'

class Mylist extends Component {
    state = {
        list: [],
        page: 5,
        count: 12

    }
    componentDidMount() {
        recommend({ page: this.state.page, count: this.state.count }).then((res) => {
            console.log(1, res.data.list);
            this.setState({
                list: res.data.list
            })
        })

    }
    render() {
        return (
            <div className='homelist'>
                <div className='today'>今日值得买</div>
                <div className='goodslist'>
                {
                    this.state.list.map((item, index) => {
                        return (

                            <div className='list' key={index}>
                                <img src={item.pic} alt="" />
                                <div className='name'>{item.name}</div>
                                <span className='price'>{item.salesPrice.name}</span>
                                <div className='buyprice'>{item.salesPrice.value}</div>
                            </div>

                        )
                    })
                }
                </div>
                
            </div>
        );
    }
}

export default Mylist;